package com.ruoyi.project.member.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.member.domain.LblCsRole;
import com.ruoyi.project.member.service.ILblCsRoleService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 角色信息Controller
 * 
 * @author BaoL
 * @date 2023-03-23
 */
@RestController
@RequestMapping("/member/role")
public class LblCsRoleController extends BaseController
{
    @Autowired
    private ILblCsRoleService lblCsRoleService;

    /**
     * 查询角色信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:role:list')")
    @GetMapping("/list")
    public TableDataInfo list(LblCsRole lblCsRole)
    {
        startPage();
        List<LblCsRole> list = lblCsRoleService.selectLblCsRoleList(lblCsRole);
        return getDataTable(list);
    }

    /**
     * 导出角色信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:role:export')")
    @Log(title = "角色信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LblCsRole lblCsRole)
    {
        List<LblCsRole> list = lblCsRoleService.selectLblCsRoleList(lblCsRole);
        ExcelUtil<LblCsRole> util = new ExcelUtil<LblCsRole>(LblCsRole.class);
        return util.exportExcel(list, "role");
    }

    /**
     * 获取角色信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:role:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lblCsRoleService.selectLblCsRoleById(id));
    }

    /**
     * 新增角色信息
     */
    @PreAuthorize("@ss.hasPermi('member:role:add')")
    @Log(title = "角色信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LblCsRole lblCsRole)
    {
        return toAjax(lblCsRoleService.insertLblCsRole(lblCsRole));
    }

    /**
     * 修改角色信息
     */
    @PreAuthorize("@ss.hasPermi('member:role:edit')")
    @Log(title = "角色信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LblCsRole lblCsRole)
    {
        return toAjax(lblCsRoleService.updateLblCsRole(lblCsRole));
    }

    /**
     * 删除角色信息
     */
    @PreAuthorize("@ss.hasPermi('member:role:remove')")
    @Log(title = "角色信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lblCsRoleService.deleteLblCsRoleByIds(ids));
    }
}
